<template>
  <div>
    <el-dropdown>
      <span class="el-dropdown-link image">
        <el-avatar :size="30"></el-avatar>
        <div class="title">{{ name }}</div>
      </span>
      <template #dropdown>
        <el-dropdown-menu>
          <el-dropdown-item @click="backLogin"
            ><i class="el-icon-circle-close"></i>退出登录</el-dropdown-item
          >
          <el-dropdown-item divided
            ><i class="el-icon-user"></i>用户信息</el-dropdown-item
          >
          <el-dropdown-item
            ><i class="el-icon-setting"></i>系统管理</el-dropdown-item
          >
        </el-dropdown-menu>
      </template>
    </el-dropdown>
  </div>
</template>

<script lang="ts">
import { defineComponent, computed } from 'vue'
import { useStore } from '../../../store/store'
import Localcache from '../../../utils/cache'
import { useRouter } from 'vue-router'
export default defineComponent({
  setup() {
    const store = useStore()
    const router = useRouter()
    const name = computed(() => store.state.login.userinfo.name)
    const backLogin = () => {
      Localcache.clearcache()
      router.push('/main')
    }
    return {
      name,
      backLogin
    }
  }
})
</script>

<style scoped lang="less">
.image {
  cursor: pointer;
  display: flex;
  .title {
    padding: 15px 5px 0 5px;
  }
}
</style>
